<?php

namespace App\Http\Controllers\Api;

use App\Entities\Permission;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use GeniusTS\Roles\Models\Role;
use Illuminate\Support\Facades\App;

class TestController extends Controller
{
    public function createRole(){
        $role = Role::create([
            'name' => 'doctor',
            'slug' => 'doctor',
            'description' => '医生',
            'level' => 3
        ]);
        return $role;
    }

    public function roleBindUser(){
        $role = Role::find(2);
        $user = User::find(7)->attachRole($role);
        return $user;
    }

    public function createPermission(){
        $permission = Permission::create([
            'name' => '测试删除病人信息2',
            'slug' => 'tss2',
            'description' => '测试删除病人信息2'
        ]);
        return $permission;
    }

    public function roleBindPermission(){
        $role = Permission::find(2);
        $user = Role::find(2)->attachPermission($role);
        return $user;
    }

    public function userBindPermission(){
        $role = Permission::find(2);
        $user = User::find(2)->attachPermission($role);
        return $user;
    }
}
